<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.icss.th.question.pojo.Question"%>
<%@ page import="com.icss.th.question.pojo.Item"%>
<%@ page import="com.icss.th.common.util.StringUtil"%>
<%@ page import="com.icss.th.common.util.SecureUtil"%>
<%
	Question q = (Question)request.getAttribute("question");
	String context = request.getContextPath();
%>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>题海——考试、复习的最佳助手</title>
<meta name="Robots" content="All">
<meta name="description" content="题海题库题目搜索引擎,汇集了近年优秀质量的题库;是一个全国各种学历考试,资格认证考试的全真在线模拟考试网站,是各类考生考前辅导学习的练兵必备工具"/>
<meta name="keywords" content="题海,题海网,学霸,题库,考试答案,题海考试试题,题海试题库,历年真题,模拟试题,预测题,公务员,报关员,建造师,造价师,会计证,会计从业,会计师,经济师,证券资格考试,英语四六级考试,职称英语,公共英语,考研,自考,计算机等级"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<script src="<%=context%>/includes/js/jquery-ui.min.js" type="text/javascript"></script>
<link href="<%=context%>/includes/css/jquery-ui.min.css" rel="stylesheet" type="text/css">
<link href="<%=context%>/includes/css/base.css" rel="stylesheet" />
<style>
h5 {
	color: #C60;
}
.t {
	font-size: 14px;
	color: #444;
	line-height: 26px;
	margin-bottom: 20px;
}
.t img {
	cursor: pointer;
}
#myselect {
	margin-bottom: 20px;
	list-style: none;
}
#myselect li {
	font-size: 14px;
	color: #06C;
	line-height: 28px;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span class="sr-only">TIHAI.ORG</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
    <a class="navbar-brand tihai-logo" href="/">&nbsp;</a> </div>
  <div class="collapse navbar-collapse navbar-ex1-collapse">
    <div class="navbar-form navbar-left" role="search">
      <div class="form-group">
        <input type="hidden" name="subjectId" id="subjectId" value="<%=q.getTypeId()%>" />
        <input type="text" name="keyword" maxlength="38" id="keyword" class="form-control" x-webkit-speech="x-webkit-speech" required   />
      </div>
      <button onclick="_submit()" class="btn btn-danger" type="button">搜索</button>
    </div>
  </div>
</nav>
<div class="container-fluid">
  <div class="row" id="m_list">
    <div class="col-sm-1"></div>
    <div class="col-sm-11">
      <div id="bdshare" class="bdshare_b" style="line-height: 12px; display:none;"> <img src="http://bdimg.share.baidu.com/static/images/type-button-1.jpg?cdnversion=20120831" /></div>
      <%-- <button onclick="AddFavorite()"   class="btn btn-success btn-xs" type="button"><span class="glyphicon glyphicon-star"></span> &nbsp; 收藏</button>--%>
    </div>
  </div>
  <div class="row">
    <div class="col-sm-1"><!----></div>
    <div class="col-sm-7"> <br>
      <h5>[本题来源]</h5>
      <div><font color="#069" ><%=q.getPaperName()%></font> ——
        <a href="<%=context%>/paper?id=<%=SecureUtil.encryptPassword(String.valueOf(q.getPaperId()))%>" id="typeOption2" ><span class="glyphicon glyphicon-list-alt"></span> &nbsp; 查看试卷</a>
      </div>
      <h5>[<%=q.getTypeName()%>] ——
        <button id="sameQ" class="btn btn-danger btn-xs disabled" type="button" >相似试题</button>
        <a id="otherfrom" href="javascript:_findSource()">使用其他来源 <span class="caret"></span></a>
        &nbsp;</h5>
      <div class="t"><%=q.getTitle()%></div>
      <hr>
      <ul id="myselect" >
        <%
        	for (Item item : q.getItems())
        	{
        %>
        <li><%=item.getSign()%>、<%=item.getContent()%><br/>
        </li>
        <%
        	}
        %>
      </ul>
      <h5>[参考答案]</h5>
      <div class="t">&nbsp; &nbsp;<%=q.getAnswer()%></div>
      <h5>[题目详解]</h5>
      <div class="t"><%=q.getExplain()%></div>
      
      <!--操作开始-->
      <div class="btn-group">
        <button class="btn btn-primary" type="button" onClick="window.location.href='/'">回首页</button>
        <button class="btn btn-default" data-toggle="collapse" data-target="#ExplainDiv" type="button">我来解析</button>
        <button class="btn btn-default" data-toggle="collapse" data-target="#CorrectDiv" type="button">纠错</button>
        <button class="btn btn-default" onClick="javascript:_findSource()" type="button">来源</button>
      </div>
      <br/>
      <br/>
      <div id="ExplainDiv" class="collapse in_del">
        <form id="explainForm" name="explainForm" method="post" action="" role="form">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">我来解析
                <button type="button" class="close" onClick="$('#ExplainDiv').collapse('toggle')">&times;</button>
              </h3>
            </div>
            <div class="panel-body">
              <textarea id="explainContent" name="explainContent"  rows="5" placeholder="输入解析内容" class="form-control" ></textarea>
            </div>
            <div class="panel-footer text-right">
              <button class="btn btn-default btn-sm" onClick="$('#ExplainDiv').collapse('toggle')"  type="button">放弃修改并关闭</button>
              &nbsp; &nbsp; &nbsp;
              <button class="btn btn-primary" onclick="_explainSubmit()"  type="button"  >添加解析</button>
            </div>
          </div>
        </form>
      </div>
      <div id="CorrectDiv" class="collapse in_del">
        <form id="correctForm" name="correctForm" method="post" action="<%=context%>/correct" role="form">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">为了方便排查错误，请您详细描述问题：
                <button type="button" class="close" onClick="$('#CorrectDiv').collapse('toggle')">&times;</button>
              </h3>
            </div>
            <div class="panel-body">
              <label class="checkbox-inline">
                <input type="checkbox" name="optionType" id="optionType_1" value="1">
                错别字 </label>
              <label class="checkbox-inline">
                <input type="checkbox" name="optionType" id="optionType_2" value="2">
                答案错误 </label>
              <label class="checkbox-inline">
                <input type="checkbox" name="optionType" id="optionType_3" value="3">
                图片模糊 </label>
              <label class="checkbox-inline">
                <input type="checkbox" name="optionType" id="optionType_4" value="4">
                题目不全 </label>
              <br>
              <br>
              <textarea id="correctContent" name="correctContent" rows="5"  placeholder="填写您的意见" class="form-control"></textarea>
            </div>
            <div class="panel-footer text-right">
              <button class="btn btn-default btn-sm"  onClick="$('#CorrectDiv').collapse('toggle')"  type="button" >放弃并关闭</button>
              &nbsp; &nbsp; &nbsp;
              <button class="btn btn-primary" onclick="_correctSubmit()"  type="button" >回报错误</button>
            </div>
          </div>
        </form>
      </div>
      <!--操作结束-->
      <%--  <div id="bdshare" class="bdshare_t bds_tools_32 get-codes-bdshare"> <a class="bds_qzone"></a> <a class="bds_tsina"></a> <a class="bds_tqq"></a> <a class="bds_renren"></a> <a class="bds_t163"></a> <span class="bds_more"></span> <a class="shareCount"></a> </div>--%>
      <ul class="pager">
        <li><a id="previous" href="<%=context%>/question?id=<%=SecureUtil.encryptPassword(String.valueOf(q.getId()))%>&paperId=<%=SecureUtil.encryptPassword(String.valueOf(q.getPaperId()))%>&sort=<%=q.getPaperSort()%>&next=-1"><strong>上一题</strong></a></li>
        <li><a id="next" href="<%=context%>/question?id=<%=SecureUtil.encryptPassword(String.valueOf(q.getId()))%>&paperId=<%=SecureUtil.encryptPassword(String.valueOf(q.getPaperId()))%>&sort=<%=q.getPaperSort()%>&next=1"><strong>下一题</strong></a></li>
      </ul>
      <!--翻页结束--> 
    </div>
    <div class="col-sm-4" id="leftFR"><!--空白--></div>
  </div>
  <div class="text-left col-sm-11 col-sm-offset-1">
    <p><a onclick="AddFavorite()" href="#">收藏</a> | <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=1003753463&site=qq&menu=yes">联系我们</a> | <a href="joinus.html" target="_blank">参与项目</a></p>
    <p> &copy;2013&nbsp;Tihai.org&nbsp;题海科技</p>
  </div>
</div>
</body>
<!--百度JS-->
<script type="text/javascript" id="bdshare_js" data="type=button&amp;uid=6832431" ></script>
<script type="text/javascript" id="bdshell_js"></script>
<script type="text/javascript">
document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000);
</script>
<!--百度分享-->
<script type="text/javascript">
	$("#keyword").keypress(function(event){
		if ( event.which == 13 ) {
			_submit();
		}
	});
	
	document.onkeydown = function(event){
	    if (window.event && window.event.keyCode == 33){
	    	window.location.href = "<%=context%>/question?id=<%=SecureUtil.encryptPassword(String.valueOf(q.getId()))%>&paperId=<%=SecureUtil.encryptPassword(String.valueOf(q.getPaperId()))%>&sort=<%=q.getPaperSort()%>&next=-1";
	    }else if (window.event && window.event.keyCode == 34){
	    	window.location.href = "<%=context%>/question?id=<%=SecureUtil.encryptPassword(String.valueOf(q.getId()))%>&paperId=<%=SecureUtil.encryptPassword(String.valueOf(q.getPaperId()))%>&sort=<%=q.getPaperSort()%>&next=1";
	    }
	};
	
	function _submit(){
		if ($.trim($("#keyword").val())){
			var path = '<%=context%>/search?';
			path += 'subjectId=' + $("#subjectId").val();
			path += '&keyword=' + encodeURI(encodeURI($("#keyword").val()));
			location.href = path;
		}else{
			location.reload();
		}
	}
	
	function _explainSubmit(){
		$.ajax({
			type:"POST",
			cache:false,
			url:"<%=context%>/explain",
			data:{
				content: $('#explainContent').val(),
				examId: '<%=SecureUtil.encryptPassword(String.valueOf(q.getId()))%>'
			},
	    	success:function(msg){
	    		if (msg) $("#content").append('<div>' + msg + '</div>');
			$('#ExplainDiv').collapse('toggle');
			}
		}); 
	}
	
	function _correctSubmit(){
		var chk_value =[];    
		$('input[name="optionType"]:checked').each(function(){    
			chk_value.push($(this).val());    
		});
		$.ajax({
			type:"POST",
			cache:false,
			url:"<%=context%>/correct",
			data:{
				content: $('#correctContent').val(),
				optionType: chk_value.toString(),
				examId: '<%=SecureUtil.encryptPassword(String.valueOf(q.getId()))%>'
			},
	    	success:function(msg){
	    		if (msg) $("#content").append('<div>' + msg + '</div>');
			$('#CorrectDiv').collapse('toggle');
			}
		}); 
	}
	
	function _findSource(){
		<%
			String ctx = StringUtil.delHTMLTag(q.getTitle());
		%>
		window.open("http://www.baidu.com/s?wd=" + encodeURI("<%=ctx.length() >= 38? ctx.substring(0, 38) : ctx%>"));
		
	}
	
	function AddFavorite(){
		var sURL = window.location;
		var sTitle = document.title;
	    try{
	        window.external.addFavorite(sURL, sTitle);
	    }catch (e){
	        try{
	            window.sidebar.addPanel(sTitle, sURL, "");
	        }catch (e){
	            alert("加入收藏失败，请使用浏览器收藏功能");
	        }
	    }
	}
	
	//给题目图片增加自适应
	$(".t img").addClass("img-responsive"); 
	$(".t img").attr("onerror","this.src='/includes/images/imgerror.png'");
	$(".t img").click(function () { _findSource();}); 
</script>

<!--统计-->
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-665718-7', 'tihai.org');
  ga('send', 'pageview');

</script>
</html>
